package com.liu.robot;

import javax.swing.*;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Hello world!
 */
public class App {

    public static void main(String[] args) {
        try {
            final MouseInfo info_frame = new MouseInfo();
            info_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            info_frame.setVisible(true);
            info_frame.setAlwaysOnTop(true);
            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    Point point = java.awt.MouseInfo.getPointerInfo().getLocation();
                    System.out.println("Location:x=" + point.x + ", y=" + point.y);
                    info_frame.value_x.setText("" + point.x);
                    info_frame.value_y.setText("" + point.y);
                }
            }, 100, 100);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
